﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;
using BeerScanatronUI.ScanatronService;

namespace BeerScanatronUI
{
    public interface IServer
    {
        /// <summary>
        /// Return true if server is connected and ready for operations.
        /// </summary>
        /// <returns></returns>
        bool IsServerPresent();

        /// <summary>
        /// Return true if bar code is already in database.
        /// </summary>
        /// <param name="barCode"></param>
        /// <returns>True on error or if barcode in use.</returns>
        bool IsDrinkerBarCodeInUse(string barCode);

        /// <summary>
        /// Return true if bar code is already in database.
        /// </summary>
        /// <param name="barCode"></param>
        /// <returns>True on error or if barcode in use.</returns>
        bool IsBeerBarCodeInUse(string barCode);

        /// <summary>
        /// Get daily beverage limit.
        /// </summary>
        /// <returns>Zero on error. Otherwise limit.</returns>
        int GetBeverageDailyLimit();

        /// <summary>
        /// Get the maximum value for the daily beverage limit.
        /// </summary>
        /// <returns>Zero on error. Otherwise limit.</returns>
        int GetMaximumBeersPerDay_UpperLimit();

        /// <summary>
        /// Set the maxiumum number of beers a drinker may consume per day.
        /// </summary>
        /// <param name="limit">From 1 to GetMaximumBeersPerDay_UpperLimit()</param>
        void SetMaximumBeersPerDay(int limit);

        /// <summary>
        /// Get image for user with barCode.
        /// </summary>
        /// <param name="badgeID"></param>
        /// <returns>Null on error. Otherwise bitmap image.</returns>
        Image GetUserImage(string barCode);

        /// <summary>
        /// Update image for user with barCode.
        /// </summary>
        /// <param name="badgeID"></param>
        /// <returns>Null on error. Otherwise bitmap image.</returns>
        void AddUpdateUserImage(string drinkerBarCode, Image image);

        /// <summary>
        /// Get drinker with barCode.
        /// </summary>
        /// <param name="barCode"></param>
        /// <returns>Null on error. Otherwise Drinker object.</returns>
        Drinker GetDrinker(string barCode);

        /// <summary>
        /// Get all drinkers.
        /// </summary>
        /// <returns>Null on error. Otherwise Drinker objects.</returns>
        IList<Drinker> GetAllDrinkers();

        /// <summary>
        /// Get number of beers drinker has had.
        /// </summary>
        /// <param name="drinkerBarCode"></param>
        /// <param name="date"></param>
        /// <returns>Number of beers</returns>
        int GetDrinkerBeersConsumedToday(string drinkerBarCode);

        /// <summary>
        /// Delete all Dispense information for all drinkers for today's date.
        /// </summary>
        void DeleteDispenseInfoForToday();

        /// <summary>
        /// Update name and can serve flag for supplied bar code.
        /// </summary>
        /// <param name="drinker"></param>
        void UpdateDrinker(Drinker drinker);

        /// <summary>
        /// Add new drinker.
        /// </summary>
        /// <param name="drinker"></param>
        void AddDrinker(Drinker drinker);

        /// <summary>
        /// Get the next largest drinker barcode.
        /// </summary>
        /// <returns></returns>
        string GetNextDrinkerBarCode();

        /// <summary>
        /// Get beer information for barCode.
        /// </summary>
        /// <param name="beverageID"></param>
        /// <returns></returns>
        Beer GetBeer(string barCode);

        /// <summary>
        /// Get beer information for BeerId
        /// </summary>
        /// <param name="BeerId"></param>
        /// <returns></returns>
        Beer GetBeer(int beerId);

        /// <summary>
        /// Add new beer.
        /// </summary>
        /// <param name="drinker"></param>
        void AddBeer(Beer beer);

        /// <summary>
        /// Get the next largest beer barcode.
        /// </summary>
        /// <returns></returns>
        string GetNextBeerBarCode();

        /// <summary>
        /// Update beer information for supplied bar code.
        /// </summary>
        /// <param name="beer"></param>
        void UpdateBeer(Beer beer);

        /// <summary>
        /// Drinker has been served.  Record information.
        /// </summary>
        /// <param name="drinkerBarCode"></param>
        /// <param name="beerBarCode"></param>
        void DispenseBeer(string drinkerBarCode, string beerBarCode);

        /// <summary>
        /// Return sales information for specified date.
        /// </summary>
        /// <param name="date"></param>
        /// <returns></returns>
        DispenserInfo[] GetDispensorsByDate(DateTime date);

        /// <summary>
        /// Get beverages sold today and their counts.
        /// </summary>
        /// <returns>Null or zero item list if no information exists.  Otherwise top beers and count served.</returns>
        IList<KeyValuePair<Beer, int>> GetBeverageSalesToday();

        /// <summary>
        /// Get top beverages sold today and their counts.
        /// </summary>
        /// <param name="date"></param>
        /// <returns>Null or zero item list if no information exists.  Otherwise top beers and count served.</returns>
        IList<KeyValuePair<Beer, int>> GetBeverageSalesByDate(DateTime date);

        /// <summary>
        /// Get dates on which at least one beverage was served and counts for types and total server.
        /// </summary>
        /// <returns>Null or zero item list if no information exists. Otherwise, list of tuples
        /// (Event date, number of types of beverages, total number of beverages sold.</returns>
        IList<Tuple<DateTime, int>> GetEventDates();
    }
}
